/* Name: Template
 * Author: John Gideon
 * Date: 5-2-12
 * Description: Template class used as a basis for other game classes
 * Revisions: See Subversion logs at http://code.google.com/p/software-engineering-2012/source/list
 */

import java.awt.Graphics2D;
import java.util.LinkedList;

public class Template extends Item {
	private static LinkedList<Template> idList = new LinkedList<Template>();
	private Sprite sprite;
	
	public Template(int px, int py) {
		Game.create((Item)this, 1); // Needed for update, draw, and destroy
		colType = COL_CIRCLE; // Needed for collision checking
		idList.add(this); // Needed for collision checking
		sprite = Sprite.load("/sprites/planets/planet3.png");
	}
	
	public void update() {}
	public void collision(Item other) {}
	public void leftMousePress(){}
	public void rightMousePress(){}
	public void leftMouseRelease(){}
	public void rightMouseRelease(){}
	
	public void destroy() {
		idList.remove(this); // Needed for collision checking
		
	}
	
	public void draw() {
		Graphics2D gh = Game.getGraphicsHandle();
		sprite.draw(gh, x, y);
	}
	
	// Function needed in each item class for collision checking
	public static int checkCollision(Item other, Boolean notify) {
		int num = 0;
		for (int i = 0; i < idList.size(); i++) {
			Item idOn = (Item)idList.get(i);
			if (idOn != other) {
				if (Item.intersection(other, idOn)) {
					if (notify) {
						idOn.collision(other);
					}
					num++;
				}
			}
		}
		return num;
	}
}
